// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#include "GameMode/Q3D_CPPA_GameMode_FighterGame.h"
#include "Input/Q3D_CPPC_InputState.h"
#include "Pawn/Q3D_CPPA_Pawn_FighterChief_ClassA.h"
#include "HUD/Q3D_CPPA_HUD_FighterGame.h"
#include "PlayerController/Q3D_CPPA_PlayerController_FighterGame.h"
#include "GameState/Q3D_CPPA_GameState_FighterGame.h"
#include "PlayerState/Q3D_CPPA_PlayerState_FighterGame.h"
#include "Pawn/Q3D_CPPA_SpectatorPawn.h"
#include "Engine/DataTable.h"
#include "Logger/Q3D_CPPU_Logger.h"

AQ3D_CPPA_GameMode_FighterGame::AQ3D_CPPA_GameMode_FighterGame()
{
    DefaultPawnClass = AQ3D_CPPA_Pawn_FighterChief_ClassA::StaticClass();
    HUDClass = AQ3D_CPPA_HUD_FighterGame::StaticClass();
    PlayerControllerClass = AQ3D_CPPA_PlayerController_FighterGame::StaticClass();
    GameStateClass = AQ3D_CPPA_GameState_FighterGame::StaticClass();
    PlayerStateClass = AQ3D_CPPA_PlayerState_FighterGame::StaticClass();
    SpectatorClass = AQ3D_CPPA_SpectatorPawn::StaticClass();

    // Q3D_CPPC_InputState 已在基类构造函数初始化
    // this->Ptr_C_InputState = CreateDefaultSubobject<UQ3D_CPPC_InputState>(TEXT("UQ3D_CPPC_PawnState"));
}

AQ3D_CPPA_GameMode_FighterGame::~AQ3D_CPPA_GameMode_FighterGame()
{
}

void AQ3D_CPPA_GameMode_FighterGame::Q3D_IF_InputState_InitDT_GetActionMapping_Implementation(UDataTable *&ptr_dt_input_action_mapping) const
{
    if (this->Ptr_DT_Input_ActionMapping)
    {
        // 子类已经对 DT 进行了赋值，就用子类的
        ptr_dt_input_action_mapping = this->Ptr_DT_Input_ActionMapping;
        Q3D_LOG(Log, "DT_Load_From_Ptr_DT_Input_ActionMapping");
        return;
    }
    // 子类未赋值 DT，就用默认地址读取
    const FString string_dt_action_mapping_path_tmp = "DataTable'/Q3D_Lib/Q3D/Input/Q3D_DT_Input_ActionMapping_FighterGame.Q3D_DT_Input_ActionMapping_FighterGame'";
    UDataTable *ptr_dt_input_action_mapping_tmp;
    // DT 的一种读法
    ptr_dt_input_action_mapping_tmp = LoadObject<UDataTable>(NULL, UTF8_TO_TCHAR(*string_dt_action_mapping_path_tmp));
    if (!ptr_dt_input_action_mapping_tmp)
    {
        Q3D_LOG(Warning, "DT_Missed_From_[" + string_dt_action_mapping_path_tmp + "]");
        ptr_dt_input_action_mapping = nullptr;
        return;
    }
    ptr_dt_input_action_mapping = ptr_dt_input_action_mapping_tmp;
    Q3D_LOG(Log, "DT_Load_From_[" + string_dt_action_mapping_path_tmp + "]");
    return;
}

void AQ3D_CPPA_GameMode_FighterGame::Q3D_IF_InputState_InitDT_GetAxisMapping_Implementation(UDataTable *&ptr_dt_input_axis_mapping) const
{
    if (this->Ptr_DT_Input_AxisMapping)
    {
        // 子类已经对DT进行了赋值，就用子类的
        ptr_dt_input_axis_mapping = this->Ptr_DT_Input_AxisMapping;
        Q3D_LOG(Log, "DT_Load_From_Ptr_DT_Input_AxisMapping");
        return;
    }
    // 子类未赋值 DT，就用默认地址读取
    const FString string_dt_axis_mapping_path_tmp = "DataTable'/Q3D_Lib/Q3D/Input/Q3D_DT_Input_AxisMapping_FighterGame.Q3D_DT_Input_AxisMapping_FighterGame'";
    UDataTable *ptr_dt_input_axis_mapping_tmp;
    // DT 的一种读法
    ptr_dt_input_axis_mapping_tmp = LoadObject<UDataTable>(NULL, UTF8_TO_TCHAR(*string_dt_axis_mapping_path_tmp));
    if (!ptr_dt_input_axis_mapping_tmp)
    {
        ptr_dt_input_axis_mapping = nullptr;
        Q3D_LOG(Warning, "DT_Missed_From_[" + string_dt_axis_mapping_path_tmp + "]");
        return;
    }
    ptr_dt_input_axis_mapping = ptr_dt_input_axis_mapping_tmp;
    Q3D_LOG(Log, "DT_Load_From_[" + string_dt_axis_mapping_path_tmp + "]");
    return;
}